<?php
//----------------------------------
//
// Alameda 0.1a (PSA)
//         Portal Script Adaptable
//
//----------------------------------
// Dario Diaz Videla 2004.
//----------------------------------
// Clase psa_formulario
// Creacion de Formularios.
//----------------------------------
class psa_formulario{
        var $item;
        var $ejecuta;
        var $formulario;
        var $alineacion;
        var $font;
        function psa_formulario(){
                $this->formulario = "psa_form1";
                $this->alineacion = "LEFT";
                $this->ejecuta    = "";
                $this->font    = "<font>";
        }
        function additem($texto, $tipo, $nombre = "", $valor = "", $extra = ""){
                $ult                 = sizeof($this->item)+1;
                if ($tipo == "0") {
                   $this->item[$ult][1] = $this->font.$texto."</font>";
                } else {
                   $this->item[$ult][1] = $texto;
                }

                $this->item[$ult][2] = $tipo;
                $this->item[$ult][3] = $nombre;
                $this->item[$ult][4] = $valor;
                $this->item[$ult][5] = $extra;


        }
        function muestra(){
                $this->alineacion = strtoupper($this->alineacion);
                if ($this->alineacion == "1" or $this->alineacion == "LEFT") {
                        $this->alineacion = "align='LEFT'";
                }else{
                        if ($this->alineacion == "2" or $this->alineacion == "CENTER") {
                                $this->alineacion = "align='CENTER'";
                        }else{
                                if ($this->alineacion == "3" or $this->alineacion == "RIGHT") {
                                        $this->alineacion = "align='RIGHT'";
                                }else{
                                        $this->alineacion = "";
                                }
                        }
                }
                $obj1             = new psa_tabla;
                $obj1->ancho      = "50%";
                $obj1->alineacion = $this->alineacion;
                $obj1->borde      = "0";

                echo "   <form name='$this->formulario' method='post' action='$this->ejecuta' enctype='multipart/form-data'>\n";
//                echo "<table width='100%' border=0 $this->alineacion>\n";
//                echo "      <tr>\n";
//                echo "         <td>\n";
                foreach($this->item as $elemento){
                        $obj1->masfila(1);
                        switch ($elemento[2]){

                                case 0 :
                                        # texto
                                        $dato = "      ".$elemento[1];
                                        break;
                                case 1 :
                                        # Input
                                        $dato = "            <input type='text' name='$elemento[3]' value='$elemento[4]' $elemento[5]>\n";
                                        break;
                                case 2 :
                                        # Password
                                        $dato = "            <input type='password' name='$elemento[3]' $elemento[5]>\n";
                                        break;
                                case 3 :
                                        #botom Send
                                        $dato = "            <input type='submit' name='$elemento[3]' value='$elemento[4]' $elemento[5]>\n";
                                        break;
                                case 4 :
                                        #botom Cancel
                                        $dato = "            <input type='reset' name='$elemento[3]' value='$elemento[4]' $elemento[5]>\n";
                                        break;
                                case 5 :
                                        #Text Area
                                        $dato = "            $elemento[1]<textarea name='$elemento[3]' rows=10 cols=40 $elemento[5]>$elemento[4]</textarea>\n";
                                        break;
                                case 6 :
                                        #Campo Hidden
                                        $dato = "            <input type='hidden' name='$elemento[3]' value='$elemento[4]' $elemento[5]>\n";
                                        break;
                                case 7 :
                                        #Campo File
                                        $dato= "            <input type='file' name='$elemento[3]' $elemento[5]>\n";
                                        break;
                        }
                        $obj1->dato(1,"\n".$dato,"left");
                }
                $obj1->muestra();
//                echo "         </td>\n";
//                echo "      </tr>\n";
//                echo "</table>\n";

                echo "</form>\n";
        }
}
?>